<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>

        /* 只要有float 首先给它一个父元素 */
    *{margin: 0;padding: 0}
    
    .nav{

        margin-left: auto;
        margin-right: auto;
        
        overflow: hidden;
        line-height: 50px;
        background: pink;

    }
    a{
        display: block;
        float: left;
        text-align: center;
        text-decoration: none;
        width: 100px;
        color: #fff;

    }
    a:hover{
        background:#eee;
        color: deeppink;
    }
    
    </style>
</head>
<body>
    <div class="nav">
        <a href="">手机</a>
        <a href="">电脑</a>
        <a href="">平板</a>
        
    </div>
</body>
</html>